<template>
  <section>
    <!--工具条-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;text-align: center">
      <el-form :inline="true" :model="query">
        <el-form-item>
          <el-input v-model="query.keyword" placeholder="Keyword" style="width:500px"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" v-on:click="search">搜索</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleAdd">新增</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onsale" plain>批量上架</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="offsale" plain>批量下架</el-button>
        </el-form-item>
      </el-form>
    </el-col>

    <!--列表-->
    <el-table :data="pageInfo.rows" highlight-current-row v-loading="listLoading" @selection-change="selsChange"
              style="width: 100%;">
      <el-table-column type="selection" width="45">
      </el-table-column>
      <el-table-column type="index" width="40">
      </el-table-column>
      <el-table-column prop="name" label="商品名" width="90" sortable>
      </el-table-column>
      <el-table-column prop="price" label="价格" width="150" sortable>
        <template v-slot="scope">
          <span v-if="scope.row.type !== 8" >{{scope.row.price}}</span>
          <span v-if="scope.row.type === 8" >
            转发:{{ getFormattedPricePart(scope.row.remarks, 'sFprice') }},
            评论:{{ getFormattedPricePart(scope.row.remarks, 'sCprice') }},
            点赞:{{ getFormattedPricePart(scope.row.remarks, 'sGprice') }}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="maxqty" label="最大数量" width="100" sortable>
        <template slot-scope="scope">
          <span v-if="scope.row.type !== 8" >{{scope.row.maxqty}}</span>
          <span v-if="scope.row.type === 8" >
            转发:{{ getFormattedmaxqty(scope.row.remarks,'sFmaxqty')}},
            评论: {{ getFormattedmaxqty(scope.row.remarks,'sCmaxqty')}},
             点赞:{{ getFormattedmaxqty(scope.row.remarks,'sGmaxqty')}}
          </span>
<!--          {{ getFormattedmaxqty(scope.row)}}-->
        </template>
      </el-table-column>
      <el-table-column prop="minqty" label="最小数量" width="100" sortable>
        <template slot-scope="scope">
          <span v-if="scope.row.type !== 8" >{{scope.row.minqty}}</span>
          <span v-if="scope.row.type === 8" >
            转发:{{getFormattedminqty(scope.row.remarks,'sFminqty')}},
            评论:{{getFormattedminqty(scope.row.remarks,'sCminqty')}},
            点赞:{{getFormattedminqty(scope.row.remarks,'sGminqty')}}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="description" label="描述" width="120" sortable>
      </el-table-column>
      <el-table-column prop="goodsImg" label="图片" width="150" sortable>
        <template slot-scope="scope">
          <div class="demo-image__preview">
            <el-image
                style="width: 100px; height: 100px"
                :src="scope.row.goodsImg"
                :preview-src-list="[scope.row.goodsImg]">
            </el-image>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="type" label="类型" width="100" sortable>
        <template slot-scope="scope">
          <span v-if="scope.row.type === 1" style="color: green;">关注</span>
          <span v-if="scope.row.type === 2" style="color: green;">转发</span>
          <span v-if="scope.row.type === 3" style="color: green;">评论</span>
          <span v-if="scope.row.type === 4" style="color: green;">点赞</span>
          <span v-if="scope.row.type === 5" style="color: green;">阅读</span>
          <span v-if="scope.row.type === 6" style="color: green;">视频播放</span>
          <span v-if="scope.row.type === 7" style="color: green;">真人评论赞</span>
          <span v-if="scope.row.type === 8" style="color: green;">统一评论赞</span>
          <span v-if="scope.row.type === 9" style="color: green;">评中评</span>
          <span v-if="scope.row.type === 10" style="color: green;">评论赞</span>
        </template>
      </el-table-column>
      <el-table-column prop="shop.name" label="店铺名" width="120" sortable>
      </el-table-column>
<!--      <el-table-column prop="auditstate" label="审核状态" width="120" sortable>-->
<!--        <template slot-scope="scope">-->
<!--          <span v-if="scope.row.auditstate === 0" style="color: red;">待审核</span>-->
<!--          <span v-if="scope.row.auditstate === 1" style="color: green;">审核通过</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column prop="state" label="上下架状态" width="120" sortable>
        <template slot-scope="scope">
          <span v-if="scope.row.state === 0" style="color: red;">已上架</span>
          <span v-if="scope.row.state === 1" style="color: green;">已下架</span>
        </template>
      </el-table-column>
<!--      <el-table-column prop="onsaletime" label="上架时间" width="160" sortable>-->
<!--      </el-table-column>-->
<!--      <el-table-column prop="offsaletime" label="下架时间" width="160" sortable>-->
<!--      </el-table-column>-->
      <el-table-column label="操作" width="220" fixed="right">
        <template scope="scope">
          <el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">删除</el-button>
          <el-button type="success" size="small" @click="handleAudit(scope.$index, scope.row)"
                     v-if="scope.row.auditstate === 0 && isAdmin()">审核
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">Batch-Delete</el-button>
      <!--      @size-change 当每页显示条数的值发生改变时会触发-->
      <!--      @current-change 当 当前页的值发生改变时会触发-->
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="query.pageSize" layout="total, sizes, prev, pager, next, jumper"
          :total="pageInfo.total"
          :current-page="query.currentPage"
          style="float: right">
      </el-pagination>
    </el-col>

    <!-- 新增/修改界面 -->
    <el-dialog title="新增/修改" :visible.sync="saveFormVisible" :close-on-click-modal="false">
      <el-form :model="saveForm" label-width="120px" :rules="saveFormRules" ref="addForm">
        <el-form-item label="商品名称" prop="name">
          <el-input v-model="saveForm.name" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="商品价格"  v-if="saveForm.type !== 8">
          <el-input type="number" v-model="saveForm.price" min="0" step="0.01" placeholder="请输入商品价格"></el-input>
        </el-form-item>
        <el-form-item label="最大数量"  v-if="saveForm.type !== 8">
          <el-input type="number" v-model="saveForm.maxqty" min="1" step="10" placeholder="请输入商品最大数量"></el-input>
        </el-form-item>
        <el-form-item label="最小数量" v-if="saveForm.type !== 8">
          <el-input type="number" v-model="saveForm.minqty" min="1" step="10" placeholder="请输入商品最小数量"></el-input>
        </el-form-item>
        <el-form-item label="商品描述">
          <el-input type="textarea" v-model="saveForm.description"></el-input>
        </el-form-item>
        <el-form-item label="商品图片">
<!--          <el-input type="textarea" v-model="saveForm.goodsImg" placeholder="请输入完整的图片url路径"></el-input>-->
          <el-upload
              class="upload-demo"
              action="http://8.217.49.47:8082/goods/upload"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :before-remove="beforeRemove"
              multiple
              :limit="1"
              :on-exceed="handleExceed"
              :on-success="handleSuccess"
              :file-list="fileList">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="商品大类类型">
          <el-select v-model="saveForm.btype" placeholder="请选择">
            <el-option
                v-for="item in regionBTOptions"
                :key="item.btype"
                :label="item.bdescription"
                :value="item.btype">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="商品小类类型" >
          <el-select v-model="saveForm.type" placeholder="请选择">
            <el-option
                v-for="item in regionTOptions"
                :key="item.type"
                :label="item.description"
                :value="item.type">
            </el-option>
          </el-select>
          <el-form-item label="转发" v-if="saveForm.type === 8">
            <div style="display: flex; align-items: center;">
              <el-input type="number" v-model="newSaveForm.sfp" min="0" step="0.01" placeholder="请输入转发价格" style="width: 200px;margin-right: 20px;"></el-input>
              <el-input type="number" v-model="newSaveForm.sfmin" min="0" step="1" placeholder="请输入转发最小数量" style="width: 200px;margin-right: 20px;"></el-input>
              <el-input type="number" v-model="newSaveForm.sfmax" min="0" step="1" placeholder="请输入转发最大数量" style="width: 200px;"></el-input>
            </div>
          </el-form-item>
          <el-form-item label="评论" v-if="saveForm.type === 8">
            <div style="display: flex; align-items: center;">
              <el-input type="number" v-model="newSaveForm.scp" min="0" step="0.01" placeholder="请输入评论价格" style="width: 200px;margin-right: 20px;"></el-input>
              <el-input type="number" v-model="newSaveForm.scmin" min="0" step="1" placeholder="请输入评论最小数量" style="width: 200px;margin-right: 20px;"></el-input>
              <el-input type="number" v-model="newSaveForm.scmax" min="0" step="1" placeholder="请输入评论最大数量" style="width: 200px;"></el-input>
            </div>
          </el-form-item>
          <el-form-item label="点赞" v-if="saveForm.type === 8">
            <div style="display: flex; align-items: center;">
              <el-input type="number" v-model="newSaveForm.sgp" min="0" step="0.01" placeholder="请输入点赞价格" style="width: 200px;margin-right: 20px;"></el-input>
              <el-input type="number" v-model="newSaveForm.sgmin" min="0" step="1" placeholder="请输入点赞最小数量" style="width: 200px;margin-right: 20px;"></el-input>
              <el-input type="number" v-model="newSaveForm.sgmax" min="0" step="1" placeholder="请输入点赞最大数量" style="width: 200px;"></el-input>
            </div>
          </el-form-item>
        </el-form-item>
        <el-form-item label="所属店铺">
          <el-select v-model="saveForm.shop" clearable value-key="id" placeholder="请选择店铺">
            <el-option
                v-for="item in Shops"
                :key="item.id"
                :label="item.name"
                :value="item">
              <span style="float: left">{{ item.name }}</span>
              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.manager.username }}</span>
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="saveFormVisible = false">取消</el-button>
        <el-button type="primary" @click.native="saveSubmit" :loading="addLoading">提交</el-button>
      </div>
    </el-dialog>

    <!-- 手动审核界面 -->
    <el-dialog title="手动审核" :visible.sync="saveAuditVisible" :close-on-click-modal="false">
      <el-form :model="saveForm" label-width="80px" :rules="saveFormRules" ref="addForm">
        <el-form-item label="商品名称" prop="name">
          <el-input v-model="saveForm.name" auto-complete="off" disabled></el-input>
        </el-form-item>
        <el-form-item label="商品价格">
          <el-input type="number" v-model="saveForm.price" disabled></el-input>
        </el-form-item>
        <el-form-item label="商品描述">
          <el-input type="textarea" v-model="saveForm.description" disabled></el-input>
        </el-form-item>
        <el-form-item label="商品类型">
          <el-radio-group v-model="saveForm.type">
            <el-radio :label="1" disabled>轮播</el-radio>
            <el-radio :label="2" disabled>评论</el-radio>
            <el-radio :label="3" disabled>点赞</el-radio>
<!--            <el-radio :label="4" disabled>评论点赞</el-radio>-->
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核选择">
          <el-radio-group v-model="examineDTO.auditstate">
            <el-radio :label="0">审核不通过</el-radio>
            <el-radio :label="1">审核通过</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="saveAuditVisible = false">取消</el-button>
        <el-button type="primary" @click.native="manualAudit" :loading="addLoading">提交</el-button>
      </div>
    </el-dialog>

  </section>
</template>

<script>


export default {
  data() {
    return {
      // 查看当前登录人的类型是商家还是管理员
      loginAccount: '',
      regionTOptions:[],
      regionBTOptions:[],
      pageInfo: {
        rows: [],
        total: 0
      },
      query: {
        currentPage: 1,
        pageSize: 20,
        keyword: "",
        // 用来区分后台接口调用还是用户端调用
        state: 1,
        accountId: '',
        accountType: ''
      },

      listLoading: false,

      sels: [],//列表选中列

      saveFormVisible: false, //编辑界面是否显示
      addLoading: false,
      saveFormRules: {
        name: [
          // {required: true, message: '请输入商品名称', trigger: 'blur'}
        ]
      },

      //编辑界面数据
      saveForm: {
        id: null,
        name: '',
        price: '',
        maxqty: '',
        minqty: '',
        description: '',
        goodsImg: '',
        type: '',
        shop: {
          id: null,
          name: ''
        },
        btype:'',
        remarks:'',
      },
      newSaveForm:{
        sfp:'',
        sfmin:'',
        sfmax:'',
        scp:'',
        scmin:'',
        scmax:'',
        sgp:'',
        sgmin:'',
        sgmax:'',
      },
      remarksData:{

      },
      fileList:[],

      // 所有店铺信息
      Shops: [],

      //手动激活data
      saveAuditVisible: false,  //手动激活界面显示
      examineDTO: {
        id: null,
        auditstate: ''
      }

    }
  },
  methods: {

    getregionTOptions(){
      this.$http.get("/type/type")
          .then(result => {
            result = result.data;
            if (result.success) {
              // this.regionOptions = result.resultObj;
              this.regionTOptions = result.resultObj.map(item => ({
                description: item.description,
                btype:item.btype,
                type:item.type,
                bdescription:item.description
              }));
            } else {
              this.$message({message: result.message, type: 'error'});
            }
          })
          .catch(result => {

          })
    },

    getregionBTOptions(){
      this.$http.get("/type/btype")
          .then(result => {
            result = result.data;
            if (result.success) {
              // this.regionOptions = result.resultObj;
              this.regionBTOptions = result.resultObj.map(item => ({
                description: item.description,
                btype:item.btype,
                type:item.type,
                bdescription:item.bdescription
              }));
            } else {
              this.$message({message: result.message, type: 'error'});
            }
          })
          .catch(result => {

          })
    },


    getFormattedmaxqty(remarks,key){
        // 默认情况或type为8时的处理逻辑
        const remarksData = JSON.parse(remarks);
        return remarksData[key] || '';
        // console.log("===================")
        // console.log(this.remarksData)
        // return "转发:"+this.remarksData.sFmaxqty+","+"评论:"+this.remarksData.sCmaxqty+","+"点赞:"+this.remarksData.sGmaxqty; // 或者返回空字符串、特殊格式等

    },
    getFormattedminqty(remarks,key){
        // 默认情况或type为8时的处理逻辑
      const remarksData = JSON.parse(remarks);
      return remarksData[key] || '';
        // return "转发:"+this.remarksData.sFminqty+","+"评论:"+this.remarksData.sCminqty+","+"点赞:"+this.remarksData.sGminqty; // 或者返回空字符串、特殊格式等
    },
    getFormattedPricePart(remarks,key) {
        // 默认情况或type为8时的处理逻辑
      const remarksData = JSON.parse(remarks);
      // console.log("===================")
        // console.log(this.remarksData)
      return remarksData[key] || ''; // 如果 key 不存在，则返回空字符串
        // return "转发:"+this.remarksData.sFprice+","+"评论:"+this.remarksData.sCprice+","+"点赞:"+this.remarksData.sGprice; // 或者返回空字符串、特殊格式等

    },

    //图片上传
    handleSuccess(response, file, fileList){
      console.log(response);
      this.saveForm.goodsImg = response;
    },
    handleRemove(file, fileList) {

      this.$http.post('/goods/remove', this.saveForm.goodsImg,{
        headers: {
          'Content-Type': 'application/json; charset=utf-8' // 设置请求头，确保以正确的编码发送数据
        }})
          .then((result) => {
        result = result.data;
        if (result.success) {
          this.$message({
            message: result.message,
            type: 'success'
          });
        } else {
          this.$message({
            message: result.message,
            type: 'error'
          });
        }
        this.getGoods();
      });
    },
    handlePreview(file) {
      // console.log('1')
      // console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${ file.name }？`);
    },

    isAdmin() {
      // 这里返回一个布尔值，表示当前用户是否是管理员
      return this.loginAccount.type === 1;
    },

    // 批量上架
    onsale() {
      var ids = this.sels.map(item => item.id);
      //获取选中的行
      if (!this.sels || this.sels.length < 1) {
        this.$message({message: '老铁，你未选中数据', type: 'error'});
        return;
      }
      this.$confirm('确认上架选中记录吗？', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        this.$http.post('/goods/onSale', ids).then((result) => {
          this.listLoading = false;
          result = result.data;
          if (result.success) {
            this.$message({
              message: result.message,
              type: 'success'
            });
          } else {
            this.$message({
              message: result.message,
              type: 'error'
            });
          }
          this.getGoods();
        });
      }).catch(() => {

      });
    },

    // 批量下架
    offsale() {
      var ids = this.sels.map(item => item.id);
      //获取选中的行
      if (!this.sels || this.sels.length < 1) {
        this.$message({message: '老铁，你未选中数据', type: 'error'});
        return;
      }
      this.$confirm('确认下架选中记录吗？', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        this.$http.post('/goods/offSale', ids).then((result) => {
          this.listLoading = false;
          result = result.data
          if (result.success) {
            this.$message({
              message: result.message,
              type: 'success'
            });
          } else {
            this.$message({
              message: result.message,
              type: 'error'
            });
          }
          this.getGoods();
        });
      }).catch(() => {

      });
    },

    selsChange: function (sels) {
      this.sels = sels;
    },

    search() {
      // 设置query.currengPage为1,当进行搜索时,从第一页开始重新进行搜索
      this.query.currentPage = 1;
      //调用查询
      this.getGoods();
    },

    handleSizeChange(val) {
      this.query.pageSize = val;
      this.query.currentPage = 1;
      //查询结果
      this.getGoods();
    },

    handleCurrentChange(val) {
      // val为当前页，赋值后重新进行查询
      this.query.currentPage = val;
      // 调用查询方法
      this.getGoods();
    },

    // 根据当前登录人获取所有店铺信息
    getShopsByUserId() {
      this.$http.get("/shop/" + this.query.accountId)
          .then(result => {
            result = result.data;
            if (result.success) {
              this.Shops = result.resultObj;
            } else {
              this.$message({message: result.message, type: 'error'});
            }
          })
          .catch(result => {
            this.$message({message: result.message, type: 'error'});
          })
    },

    //手动审核弹框
    handleAudit: function (index, row) {
      this.saveAuditVisible = true;
      this.saveForm = Object.assign({}, row);
      this.examineDTO.id = row.id;
    },

    // 手动审核提交
    manualAudit() {
      this.$confirm('确认提交吗？', '提示', {}).then(() => {
        this.addLoading = true;
        var para = this.examineDTO;
        this.$http.post("/goods/audit", para)
            .then(result => {
              result = result.data;
              if (result.success) {
                //从第一页开始展示
                this.query.currentPage = 1;
                this.getGoods();
                //关闭加载框
                this.addLoading = false;
                //关闭弹框
                this.saveAuditVisible = false;
                this.$message({message: result.message, type: 'success'});
              } else {
                //关闭加载框
                this.addLoading = false;
                //关闭弹框
                this.saveAuditVisible = false;
                this.$message({message: result.message, type: 'error'});
              }
            }).catch(result => {
          this.$message({message: result.message, type: 'error'});
        })
      });
    },

    //获取商品列表
    getGoods() {
      this.$http.post("/goods/page", this.query)
          .then(result => {
            result = result.data;
            if (result.success) {
              this.pageInfo = result.resultObj;
              // const jsonString = this.pageInfo.rows.remarks;
              // this.pageInfo.rows.remarks = JSON.parse(jsonString);
              console.log(this.pageInfo.rows)
            } else {
              this.$message({message: result.message, type: 'error'});
            }
          })
          .catch(result => {

          })
    },

    //根据id删除数据
    handleDel: function (index, row) {
      this.$confirm('确认删除该商品吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        this.$http.delete("/goods/" + row.id)
            .then(result => {
              result = result.data;
              this.listLoading = false;
              if (result.success) {
                this.$message({message: '删除成功', type: 'success'});
                //删除成功后回到第一页
                this.query.currentPage = 1;
                // 删除成功,要重新刷新该页面，调用方法查询
                this.getGoods();
              } else {
                this.$message({message: result.message, type: 'error'});
              }
            })
            .catch(result => {
              // this.$message({message: '很抱歉，网络有误', type: 'error'});
            })
      }).catch(() => {
        this.$message({message: '已取消删除', type: 'info'});
      });
    },

    //批量删除数据
    batchRemove: function () {
      //遍历选中的sels数组的id值给ids
      var ids = this.sels.map(item => item.id);
      this.$confirm('确认删除选中记录吗？', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        // 调用批量删除接口
        this.$http.patch("/goods", ids)
            .then(result => {
              result = result.data;
              this.listLoading = false;
              if (result.success) {
                this.$message({message: '批量删除成功!', type: 'success'});
                //删除后回到第一页
                this.query.currentPage = 1;
                //调用查询
                this.getGoods();
              } else {
                this.$message({message: result.message, type: 'error'});
              }
            })
      }).catch(() => {
        this.$message({message: "网络错误", type: 'error'});
      });
    },

    //显示修改界面(回显数据)
    handleEdit: function (index, row) {
      this.saveFormVisible = true;
      this.getShopsByUserId();
      this.saveForm = Object.assign({}, row);
    },

    //显示新增界面
    handleAdd: function () {
      this.saveFormVisible = true;
      this.getShopsByUserId();
      this.saveForm = {
        id: null,
        name: '',
        price: '',
        description: '',
        goodsImg: '',
        type: '',
        shop: {
          id: null,
          name: ''
        }
      };
      this.getregionTOptions();
      this.getregionBTOptions();
    },
    updateRemarks() {
      // 构建一个包含价格和最小数量的JSON对象
      this.saveForm.remarks = JSON.stringify({
        sFprice: this.newSaveForm.sfp,
        sFminqty: this.newSaveForm.sfmin,
        sFmaxqty: this.newSaveForm.sfmax,
        sCprice: this.newSaveForm.scp,
        sCminqty: this.newSaveForm.scmin,
        sCmaxqty: this.newSaveForm.scmax,
        sGprice: this.newSaveForm.sgp,
        sGminqty: this.newSaveForm.sgmin,
        sGmaxqty: this.newSaveForm.sgmax,
      });
    },
      //提交
    saveSubmit: function () {
      this.updateRemarks();
      console.log(this.saveForm)
      this.$refs.addForm.validate((valid) => {
        if (valid) {
          this.$confirm('确认提交吗？', '提示', {}).then(() => {
            this.addLoading = true;
            var para = this.saveForm;
            this.$http.put("/goods/", para)
                .then(result => {
                  result = result.data;
                  if (result.success) {
                    //从第一页开始展示
                    this.query.currentPage = 1;
                    this.getGoods();
                    //关闭加载框
                    this.addLoading = false;
                    //关闭弹框
                    this.saveFormVisible = false;
                    this.$message({message: result.message, type: 'success'});
                  } else {
                    this.$message({message: result.message, type: 'error'});
                  }
                }).catch(result => {
              this.$message({message: result.message, type: 'error'});
            })
          });
        }
      });
    },

  },

  mounted() {
    // 钩子函数，页面加载后，调用此方法
    this.loginAccount = JSON.parse(localStorage.getItem("loginUser"))
    this.query.accountId = this.loginAccount.id;
    this.query.accountType = this.loginAccount.type;
    this.getGoods();
  }
}

</script>

<style scoped>

</style>
